﻿// Public Class SQLite
// Implements BaseConnection

// ''' <summary>
// ''' 使用所指定的属性设置关闭数据库连接
// ''' </summary>
// ''' <remarks></remarks>
// Public Sub Close() Implements BaseConnection.Close
// If Me.ConnectionString <> Nothing Then
// If Me.State <> ConnectionState.Closed Then
// Me.Connection.Close()
// End If
// End If
// End Sub

// Public Property ConnectionString As String Implements BaseConnection.ConnectionString
// Get
// If Me._Connection IsNot Nothing Then
// Return Me._Connection.ConnectionString
// Else
// Return m_ConnectionString
// End If
// End Get
// Set(ByVal value As String)
// If Me._Connection IsNot Nothing Then
// Me._Connection.ConnectionString = value
// Else
// m_ConnectionString = value
// End If
// End Set
// End Property
// Private m_ConnectionString As String
// Public ReadOnly Property ConnectionVersion As ConnectionVersionEnum Implements BaseConnection.ConnectionVersion
// Get
// Return ConnectionVersionEnum.SQLite
// End Get
// End Property

// ''' <summary>
// ''' 返回数据源指定表的字段结构
// ''' </summary>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public Function GetColumns(ByVal TableName As String) As System.Data.DataTable Implements BaseConnection.GetColumns
// Return Me.GetColumns(TableName, Nothing)
// End Function

// ''' <summary>
// ''' 返回数据源指定表的字段结构
// ''' </summary>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public Function GetColumns(ByVal TableName As String, ParamArray ColNames As String()) As System.Data.DataTable
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// Dim list As New List(Of String)
// dt = Me.Connection.GetSchema("Columns", {Nothing, Nothing, TableName})
// Me.Close()
// If ColNames.Length > 0 Then
// Return dt.DefaultView.ToTable(False, ColNames)
// End If
// Return dt
// Catch ex As System.Exception
// Me.Close()
// Throw ex
// End Try
// End Function

// Public Function GetConnection(Of T)() As T Implements BaseConnection.GetConnection
// Return CType(Me.Connection, Object)
// End Function

// Public Function GetDate() As Date Implements BaseConnection.GetDate
// Dim obj As Date = Nothing
// Select Case Me.ConnectionVersion
// Case ConnectionVersionEnum.MsSql2000, ConnectionVersionEnum.MsSql2005, ConnectionVersionEnum.MsSql2008
// Dim cmd As New SQLCommand(Me.Name, "Select datetime()")
// obj = CDate(cmd.ExecuteScalar)
// End Select
// If obj = Nothing Then
// obj = Date.Now
// End If
// Return obj
// End Function

// Public Function GetProceduresNames() As List(Of String) Implements BaseConnection.GetProceduresNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("Procedures")
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("ROUTINE_NAME"))
// Next
// Return list
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Function GetTableNames() As List(Of String) Implements BaseConnection.GetTableNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("TABLES", {Nothing, Nothing, Nothing, "BASE TABLE"})
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("Table_NAME"))
// Next
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Function GetViewNames() As List(Of String) Implements BaseConnection.GetViewNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("TABLES", {Nothing, Nothing, Nothing, "VIEW"})
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("Table_NAME"))
// Next
// Return list
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Property Name As String Implements BaseConnection.Name

// Public Sub Open() Implements BaseConnection.Open
// If Me.ConnectionString <> Nothing Then
// If Me.State <> ConnectionState.Open Then
// Me.Connection.Open()
// End If
// End If
// End Sub

// Public ReadOnly Property SourceType As SourceType Implements BaseConnection.SourceType
// Get
// Return Data.SourceType.SQLite
// End Get
// End Property

// Public ReadOnly Property State As ConnectionState Implements BaseConnection.State
// Get
// Return Me.Connection.State
// End Get
// End Property

// ''' <summary>
// ''' 返回数据源的System.Data.OleDb.OleDbConnection
// ''' </summary>
// ''' <value></value>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public ReadOnly Property Connection As System.Data.SQLite.SQLiteConnection
// Get
// If Me._Connection Is Nothing Then
// Me._Connection = New System.Data.SQLite.SQLiteConnection(Me.ConnectionString)
// End If
// Return Me._Connection
// End Get
// End Property
// Private _Connection As System.Data.SQLite.SQLiteConnection
// End Class
// Public Class SQLite
// Implements BaseConnection

// ''' <summary>
// ''' 使用所指定的属性设置关闭数据库连接
// ''' </summary>
// ''' <remarks></remarks>
// Public Sub Close() Implements BaseConnection.Close
// If Me.ConnectionString <> Nothing Then
// If Me.State <> ConnectionState.Closed Then
// Me.Connection.Close()
// End If
// End If
// End Sub

// Public Property ConnectionString As String Implements BaseConnection.ConnectionString
// Get
// If Me._Connection IsNot Nothing Then
// Return Me._Connection.ConnectionString
// Else
// Return m_ConnectionString
// End If
// End Get
// Set(ByVal value As String)
// If Me._Connection IsNot Nothing Then
// Me._Connection.ConnectionString = value
// Else
// m_ConnectionString = value
// End If
// End Set
// End Property
// Private m_ConnectionString As String
// Public ReadOnly Property ConnectionVersion As ConnectionVersionEnum Implements BaseConnection.ConnectionVersion
// Get
// Return ConnectionVersionEnum.SQLite
// End Get
// End Property

// ''' <summary>
// ''' 返回数据源指定表的字段结构
// ''' </summary>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public Function GetColumns(ByVal TableName As String) As System.Data.DataTable Implements BaseConnection.GetColumns
// Return Me.GetColumns(TableName, Nothing)
// End Function

// ''' <summary>
// ''' 返回数据源指定表的字段结构
// ''' </summary>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public Function GetColumns(ByVal TableName As String, ParamArray ColNames As String()) As System.Data.DataTable
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// Dim list As New List(Of String)
// dt = Me.Connection.GetSchema("Columns", {Nothing, Nothing, TableName})
// Me.Close()
// If ColNames.Length > 0 Then
// Return dt.DefaultView.ToTable(False, ColNames)
// End If
// Return dt
// Catch ex As System.Exception
// Me.Close()
// Throw ex
// End Try
// End Function

// Public Function GetConnection(Of T)() As T Implements BaseConnection.GetConnection
// Return CType(Me.Connection, Object)
// End Function

// Public Function GetDate() As Date Implements BaseConnection.GetDate
// Dim obj As Date = Nothing
// Select Case Me.ConnectionVersion
// Case ConnectionVersionEnum.MsSql2000, ConnectionVersionEnum.MsSql2005, ConnectionVersionEnum.MsSql2008
// Dim cmd As New SQLCommand(Me.Name, "Select datetime()")
// obj = CDate(cmd.ExecuteScalar)
// End Select
// If obj = Nothing Then
// obj = Date.Now
// End If
// Return obj
// End Function

// Public Function GetProceduresNames() As List(Of String) Implements BaseConnection.GetProceduresNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("Procedures")
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("ROUTINE_NAME"))
// Next
// Return list
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Function GetTableNames() As List(Of String) Implements BaseConnection.GetTableNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("TABLES", {Nothing, Nothing, Nothing, "BASE TABLE"})
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("Table_NAME"))
// Next
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Function GetViewNames() As List(Of String) Implements BaseConnection.GetViewNames
// Dim list As New List(Of String)
// Try
// Me.Open()
// Dim dt As System.Data.DataTable
// dt = Me.Connection.GetSchema("TABLES", {Nothing, Nothing, Nothing, "VIEW"})
// For Each dr As System.Data.DataRow In dt.Rows
// list.Add(dr("Table_NAME"))
// Next
// Return list
// Catch ex As System.Exception
// Throw ex
// Finally
// Me.Close()
// End Try
// Return list
// End Function

// Public Property Name As String Implements BaseConnection.Name

// Public Sub Open() Implements BaseConnection.Open
// If Me.ConnectionString <> Nothing Then
// If Me.State <> ConnectionState.Open Then
// Me.Connection.Open()
// End If
// End If
// End Sub

// Public ReadOnly Property SourceType As SourceType Implements BaseConnection.SourceType
// Get
// Return Data.SourceType.SQLite
// End Get
// End Property

// Public ReadOnly Property State As ConnectionState Implements BaseConnection.State
// Get
// Return Me.Connection.State
// End Get
// End Property

// ''' <summary>
// ''' 返回数据源的System.Data.OleDb.OleDbConnection
// ''' </summary>
// ''' <value></value>
// ''' <returns></returns>
// ''' <remarks></remarks>
// Public ReadOnly Property Connection As System.Data.SQLite.SQLiteConnection
// Get
// If Me._Connection Is Nothing Then
// Me._Connection = New System.Data.SQLite.SQLiteConnection(Me.ConnectionString)
// End If
// Return Me._Connection
// End Get
// End Property
// Private _Connection As System.Data.SQLite.SQLiteConnection
// End Class
